package com.jxtc.enterprise.hr.vo;

import com.jxtc.enterprise.common.enums.ShowVipUserFoodEnum;
import com.jxtc.enterprise.hr.dto.EmployeeDepartmentDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

@Schema(description = "员工信息")
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class EmployeeVO {

    @Schema(description = "员工 ID", example = "c752804d0cd410267f404dd3f0457a57")
    private String id;

    @Schema(description = "员工姓名", example = "张三")
    private String name;

    @Schema(description = "部门", example = "技术部")
    private String department;

    @Schema(description = "手机号码", example = "13800138000")
    private String phoneNumber;

    @Schema(description = "余额，单位：元", example = "100.00")
    private Integer balance;

    @Schema(description = "密码", example = "123456")
    private String password;

    @Schema(description = "员工每餐限购份额", example = "1")
    private Integer limitCount;

    /**
     * 其它可点餐公司名称列表，使用 ", " 拼接后返回
     */
    private String otherCanOrderFoodCompanyName = "";

    /**
     * 是否显示客户餐
     */
    private boolean showVipUserFoodBtn = false;

    public EmployeeVO(EmployeeDepartmentDTO dto) {
        this.id = dto.getId();
        this.name = dto.getUsername();
        this.department = dto.getDepartmentName();
        this.phoneNumber = dto.getPhoneNumber();
        this.balance = dto.getBalance();
        this.password = dto.getPassword();
        this.limitCount = dto.getLimitCount();

        if (dto.getShowVipFoodBtn() != null) {
            this.showVipUserFoodBtn = dto.getShowVipFoodBtn().equals(ShowVipUserFoodEnum.SHOW_VIP_USER_FOOD.getValue());
        }
    }

    public double getBalance() {
        return balance / 100.0;
    }
}
